package com.itheima.day14.day14work2;

public class TeoPeople implements  Runnable {
    private final LiPin lp;

    public TeoPeople(LiPin lp) {
        this.lp =lp;
    }

    @Override
    public void run() {
        while (true){
            synchronized (lp.getObj()){
                int num = lp.getNum();
                if (num<=10){
                    break;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"送出礼品，还剩下"+(--num));
                lp.setNum(num);

            }
        }
    }
}
